package com.rainbow.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rainbow.entity.Role;
import com.rainbow.mapper.RoleMapper;
import com.rainbow.service.RoleService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;

/**
 * @Author rainbow
 **/
@Service
@Transactional
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {
    @Override
    public List<Role> roles() {
        return baseMapper.roles();
    }

    @Override
    public int addNewRole(String role, String roleZh) {
        if (!role.startsWith("ROLE_")) {
            role = "ROLE_" + role;
        }
        return baseMapper.addNewRole(role, roleZh);
    }

    @Override
    public int deleteRoleById(Long rid) {
        return baseMapper.deleteRoleById(rid);
    }
}
